package com.atguigu01._this.exer2;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/10/25 11:25
 * @Version 1.0
 */
public class Bank {
    private Customer[] customers;//用于保存多个客户
    private int numderofCustomer;//记录储存的个数

    public Bank(){
        //初始化
        customers = new Customer[10];
    }

    /**
     * 将指定姓名的客户保存在银行的客户列表中
     * @param f
     * @param l
     */
    public void addCustomer(String f,String l){
        //存储cust客户
        Customer cust = new Customer(f,l);
        //为customers数组赋值，避免空间浪费
        customers[numderofCustomer]=cust;
        numderofCustomer++;//个数++
    }

    /**
     * 获取客户列表中存储的客户的个数
     * @return
     */
    public int getNumderofCustomer(){
        return numderofCustomer;
    }

    /**
     * 获取指定索引位置上的客户
     * @param index
     * @return
     */
    public Customer getCustomer(int index){
        if(index < 0 || index >= numderofCustomer){
            return null;
        }
        return customers[index];
    }
}
